  #!/bin/bash 
   . /etc/profile
   . ~/.bash_profile 
 
   cd   /home/ulss/project/dpl-data-indexer/log

   if [ $# -lt 2 ]
     then 
       echo  " stat_idx_datacount.sh time datatype " 
       exit 0 
     fi
    
    currentDateStr=`date +%Y-%m-%d`
    
    time="$1"
    type="$2"
    file=""
     
    dateStr=`echo "$time" |awk '{print $1}'`

   
     if [ "$dateStr" = "$currentDateStr" ]
      then 
          file="Indexer.log"
      else
	  file=`echo "Indexer.log.$dateStr"|awk '{print $1}'`
      fi
      
    echo -e -n  "receive $type \"$time\":" 
    rm -rf .count
    echo " grep \" get data \" "$file"|grep \"$time\"|grep "$type" |awk '{print $NF}'"|sh>>.count
    cat .count | awk 'BEGIN{sum=0}{sum=sum+$NF}END{print  sum}'
    rm -rf .count


    echo -e -n  "write $type \"$time\":"
    rm -rf .count
    echo  " grep \"write lucene file \" "$file"|grep \"$time\"|grep "$type" |awk '{print $NF}'" |sh>>.count
    cat .count | awk 'BEGIN{sum=0}{sum=sum+$NF}END{print  sum}'
    rm -rf .count



    #begin=$(head -n 1 .count|awk '{print $NF}')
    #end=$(tail -n 1 .count|awk '{print $NF}')
    #sum=$(($end-$begin))
